import 'dart:convert';
import 'package:flutter_company_app/conf/config.dart';
import 'package:http/http.dart' as http;

// 获取产品数据
getProductResult([int page = 0]) async {
  var url = Uri.http("${Config.IP}:${Config.PORT}", '/',
      {'action': 'getProducts', 'page': "$page"});
  var response = await http.get(url);
  if (response.statusCode == 200) {
    var jsonResponse = json.decode(response.body);
    print("数据请求成功");
    return jsonResponse['items'];
  } else {
    print('Request failed with status: ${response.statusCode}.');
  }
}
